﻿<div ng-controller="orderController">
    <div class="wrapper border-bottom white-bg page-heading">
        <div class="col-lg-pull-12">
            <ol class="breadcrumb">
                <li>订单</li>
            </ol>
        </div>
    </div>

    <form class="form-horizontal row">
        <div class="form-group">
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">订单号</label>
                <div class="col-sm-8">
                    <input name="order_no" type="text" class="form-control input-sm" ng-model="query.order_no">
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">账号/名称</label>
                <div class="col-sm-8">
                    <input name="q" type="text" class="form-control input-sm" ng-model="query.q">
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">状态</label>
                <div class="col-sm-8">
                    <select class="form-control input-sm" ng-model="query.order_status">
                        <option value="">全部</option>
                        <option value="1">待支付</option>
                        <option value="2">待发货</option>
                        <option value="3">待收货</option>
                        <option value="4">已完成</option>
                    </select>
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">订单时间</label>
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.start_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.end_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-4">
                <div class="col-sm-offset-4 col-sm-8">
                    <a class="btn btn-primary btn-sm" ui-sref="app.order.list(query)"><i class="fa fa-search"></i> 查询</a>
                    <a class="btn btn-primary btn-sm" ng-click="search()"><i class="fa fa-refresh"></i> 刷新</a>
                    <!--<button class="btn btn-primary btn-sm"><i class="fa fa-download"></i> 导出</button>-->
                </div>
            </div>
        </div>
    </form>
    <!--<table class="table table-hover m-t-md">
        <thead>
            <tr style="background-color: #f7f7f9;">
                <th>支付单号</th>
                <th>订单金额</th>
                <th>应付金额</th>
                <th>手续费</th>
                <th>实收金额</th>
                <th>订单时间</th>
                <th>订单状态</th>
                <th width="65">操作</th>
            </tr>
        </thead>
        <tbody ng-repeat="item in model">

            <tr ng-if="item.orders.length>0&&item.orders[0].status==2">
                <td colspan="9">
                    <p>支付方式：{{item.pay_name}} 交易号：{{item.pay_no}} 支付流水号：{{item.transaction_no}} <a class="btn btn-primary btn-xs" ng-if="item.orders[0].status==2" ng-click="order_delivery(item.id)"><i class="fa fa-cog"></i>备货</a> </p>
                </td>
            </tr>
            <tr ng-if="item.orders.length>0&&item.orders[0].status==2">
                <td colspan="9">
                    <table class="table  m-t-md">
                        <tr ng-repeat="items in item.orders">
                            <td>{{items.order_no}}</td>
                            <td>{{items.merchant.nick}}<br />{{items.merchant.mobile}}</td>

                            <td>{{items.order_amount}}</td>
                            <td>{{items.subsidy_amount}}</td>
                            <td>{{items.pay_amount}}</td>
                            <td>{{items.fee_amount}}</td>
                            <td>{{items.amount}}</td>
                            <td>{{items.order_time}}</td>
                            <td>{{get_order_status(items.status)}}</td>
                            <td>

                                <a class="btn btn-primary btn-xs" ui-sref="app.order.detail({id:{{items.id}}})"><i class="fa fa-cog"></i> 详情</a>

                            </td>

                        </tr>

                    </table>
                </td>


            </tr>
        </tbody>
    </table>-->
    <table class="table table-hover m-t-md">
        <thead>
            <tr style="background-color: #f7f7f9;">
                <th>订单号</th>
                <th>商户</th>
                <th>状态</th>
                <th>订单金额</th>
                <th>补贴</th>
                <th>应付金额</th>
                <th>手续费</th>
                <th>实收金额</th>
                <th>订单时间</th>
                <th width="65">操作</th>
            </tr>
        </thead>
        <tbody ng-repeat="item in model.rows">
            <tr>
                <td colspan="10">
                    <p>支付方式：{{item.pay_info.pay_name}} 交易号：{{item.pay_info.pay_no}} 支付流水号：{{item.pay_info.transaction_no}} </p>
                </td>
            </tr>
            <tr>
                <td>{{item.order_no}}</td>
                <td>{{item.shipping.ship_to}}<br />{{item.merchant.mobile}}</td>
                <td>{{item.status==1?"待支付":(item.status==2?"已支付":"已关闭")}}</td>
                <td>{{item.order_amount > 0 || item.red_drill == 0 ? item.order_amount :""}}{{item.order_amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.subsidy_amount}}</td>
                <td>{{item.pay_amount > 0 || item.red_drill == 0 ? item.pay_amount :""}}{{item.pay_amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.fee_amount}}</td>
                <td>{{item.amount > 0 || item.red_drill == 0 ? item.amount :""}}{{item.amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.order_time}}</td>
                <td>
                    <a class="btn btn-primary btn-xs" ui-sref="app.order.detail({id:{{item.id}}})"><i class="fa fa-cog"></i> 详情</a>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="row">
        <div class="col-md-12">
            <uib-pagination total-items="model.total_result" items-per-page="model.size" ng-model="model.page" num-pages="model.total_pages"
                            ng-change="search_page(model.page)" class="pagination-sm" boundary-links="true" boundary-link-numbers="true" max-size="20"
                            previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></uib-pagination>
            <span class="pull-right" style="margin: 30px 0px 20px 0px">共{{model.total_result}} 当前：{{model.page}}/{{model.total_pages}}</span>
        </div>
    </div>
</div>
